
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Entity;
using Data;
using Quadrem.ExceptionManagement;

namespace Business
{
	public class BLPlanAdmision
	{

        public static DataTable ListarPlanesAdmision()
        {
            DataTable dtPlanAdmision = null;
            try
            {
                dtPlanAdmision = DAPlanAdmision.ListarPlanesAdmision();
            }
            catch (Exception ex)
            {
                BusinessLogicBase.Publish(ex);
            }
            return dtPlanAdmision;
        }

     
        public static BEPlanAdmision ObtenerPlanAdmisionVigente()
		{
            BEPlanAdmision oPlanAdmision = null;
            try
            {
                DataSet dsPlanAdmision = DAPlanAdmision.ObtenerPlanAdmisionVigente();
                if (dsPlanAdmision.Tables.Count > 0 && dsPlanAdmision.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = dsPlanAdmision.Tables[0].Rows[0];
                    oPlanAdmision = new BEPlanAdmision();
                    oPlanAdmision.CodPlanAdmision = dr["CodPlanAdmision"].ToString();
                    oPlanAdmision.Descripcion = dr["Descripcion"].ToString();
                    //oPeriodo.Estado = dr["Estado"].ToString();
                }
            }
            catch (Exception ex)
            {
                BusinessLogicBase.Publish(ex);
            }
            return oPlanAdmision;
        }

        public static BEPlanAdmision ObtenerUltimoPlan()
        {
            BEPlanAdmision oPlanAdmision = null;
            try
            {
                DataSet dsPlanAdmision = DAPlanAdmision.ObtenerUltimoPlan();
                if (dsPlanAdmision.Tables.Count > 0 && dsPlanAdmision.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = dsPlanAdmision.Tables[0].Rows[0];
                    oPlanAdmision = new BEPlanAdmision();
                    oPlanAdmision.CodPlanAdmision = dr["CodPlanAdmision"].ToString();
                    oPlanAdmision.Descripcion = dr["Descripcion"].ToString();
                    //oPeriodo.Estado = dr["Estado"].ToString();
                }
            }
            catch (Exception ex)
            {
                BusinessLogicBase.Publish(ex);
            }
            return oPlanAdmision;
        }

        public static BEPlanAdmision ObtenerPlanAdmision(string strCodPlanAdmision)
        {
            BEPlanAdmision oPlanAdmision = null;
            try
            {
                DataSet dsPlanAdmision = DAPlanAdmision.ObtenerPlanAdmision(strCodPlanAdmision);
                if (dsPlanAdmision.Tables.Count > 0 && dsPlanAdmision.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = dsPlanAdmision.Tables[0].Rows[0];
                    oPlanAdmision = new BEPlanAdmision();
                    oPlanAdmision.CodPlanAdmision = dr["CodPlanAdmision"].ToString();
                    oPlanAdmision.Descripcion = dr["Descripcion"].ToString();
                    oPlanAdmision.FecInicio = Convert.ToDateTime(dr["FecInicio"]);
                    oPlanAdmision.FecFinVigencia = Convert.ToDateTime(dr["FecFinVigencia"]);
                    oPlanAdmision.Estado = Convert.ToInt16(dr["Estado"]);
                }
            }
            catch (Exception ex)
            {
                BusinessLogicBase.Publish(ex);
            }
            return oPlanAdmision;
        }
        
        public static void RegistrarPlanAdmision(BEPlanAdmision oPlanAdmision)
        {
            try
            {
                DAPlanAdmision.RegistrarPlanAdmision(oPlanAdmision);
            }
            catch (Exception ex)
            {
                BusinessLogicBase.Publish(ex);
            }
        }
        public static void CierraProceso(string strCodProceso, string strUsuMod)
        {
            try
            {
                DAPlanAdmision.CierraProceso(strCodProceso, strUsuMod);
            }
            catch (Exception ex)
            {
                BusinessLogicBase.Publish(ex);
            }
        }

    }
}
      